﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO;
using System.IO.IsolatedStorage;
using System.Text;
using System.Xml.Linq;

using Microsoft.Phone.Tasks;
using AMobiSDK;

namespace Sai_Se_Dung
{
    public partial class HighScore : PhoneApplicationPage
    {
        Score score;
        public HighScore()
        {
            InitializeComponent();
            PlayBackgroundSound();
            score = new Score();
            txtHighScore.Text = score.ReadScore().ToString();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            AdManager.setWidgetCode("f2257ad5570a4a773a2edd33504ef3c2");//Bạn phải thay mã này bằng widgetCode của bạn
            AdManager advertisement = new AdManager();
            advertisement.OnNavigationTo(this, null, null, banner);
        }

        private void PlayBackgroundSound()
        {
            if (Option.isOn == true)
            {
                mp3_highscore.AutoPlay = true;
                mp3_highscore.Play();
            }
            else
            {
                mp3_highscore.AutoPlay = false;
                mp3_highscore.Stop();
            }
        }

        private void mp3_highscore_MediaEnded(object sender, RoutedEventArgs e)
        {
            PlayBackgroundSound();
        }

        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            if (Option.isOn == true)
            {
                mp3_btn.Play();
            }
        }

        private void btnShareScore_Click(object sender, RoutedEventArgs e)
        {
            if (Option.isOn == true)
            {
                mp3_btn.Play();
            }
            ShareLinkTask shareLinkTask = new ShareLinkTask();
            shareLinkTask.Title = "FALSE is TRUE";
            shareLinkTask.LinkUri = new Uri("http://www.windowsphone.com/s?appid=38605eec-1bc6-49a3-8a5e-53e88555da9d", UriKind.Absolute);//cho linh cua minh vao
            shareLinkTask.Message = "I've got " + new Score().ReadScore().ToString() + " scores!";
            shareLinkTask.Show();
        }
    }
}